package com.lintf.nacos.service;

import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.api.naming.NamingFactory;
import com.alibaba.nacos.api.naming.NamingService;

import java.io.IOException;

/**
 * @author lin tingfeng
 * @ system Mac
 * @ data 2025/3/21 09:55
 * @ package_name com.lintf.nacos.service
 * @ project_name spring-nacos
 * @ desc SDK方式注册服务
 */
public class SpringNacosServiceMain {

    public static void main(String[] args) throws NacosException, IOException {
        // 注册服务1
        NamingService namingService = NamingFactory.createNamingService("localhost:8848");
        namingService.registerInstance("spring-nacos-jdk", "11.11.11.11", 8888, "cluster1");

        // 注册服务2
        NamingService namingService1 = NamingFactory.createNamingService("localhost:8848");
        namingService1.registerInstance("spring-nacos-jdk", "11.11.11.12", 8888, "cluster1");

        // 注册服务3
        NamingService namingService2 = NamingFactory.createNamingService("localhost:8848");
        namingService2.registerInstance("spring-nacos-jdk", "11.11.11.13", 8888, "cluster2");
        System.in.read();
    }

}
